package com.topfun.misc;


import com.topfun.utils.MenuUtil;
import com.topfun.utils.WechatUtil;
import com.topfun.vo.*;

/**
 * 菜单管理类,用于菜单的创建
 *
 * @author Administrator
 */
public class MenuManager {
//	private static Logger log = LoggerFactory.getLogger(MenuManager.class);
    public static final String Customer_Service_Key = "Contact_Customer_Service";
    public static void main(String[] args) {

        // 调用接口获取access_token
        AccessToken at = WechatUtil.accessToken;
        if (null != at) {
            // 调用接口创建菜单
            boolean result = MenuUtil.createMenu(getMenu(), at.getToken());
            // 判断菜单创建结果
            if (result)
                System.out.println("菜单创建成功！");
            else
                System.out.println("菜单创建失败，错误码：" + result);
        }
    }

    /**
     * 组装菜单数据
     *
     * @return
     */
    public static Menu getMenu() {

        //============game button=================
        ViewButton menuTopfun = new ViewButton();
        menuTopfun.setName("幸运乐翻天");
        menuTopfun.setType("view");
        menuTopfun.setUrl("http://www.tuiclubs.com");

        ComplexButton menuGame = new ComplexButton();
        menuGame.setName("游戏");
        menuGame.setSub_button(new Button[]{menuTopfun});
        //=============联系客服button======================
        ClickButton menuCustomerService = new ClickButton();
        menuCustomerService.setName("联系客服");
        menuCustomerService.setType("click");
        menuCustomerService.setKey(Customer_Service_Key);

        Menu menu = new Menu();
        menu.setButton(new Button[]{menuGame,menuCustomerService});

        return menu;
    }
}
